package cn.rxls.admin.shop.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @作者：不想说话而已
 * @Date：2024/5/10 2:20
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data){
        Result<T> r = new Result<>();
        r.code = 200;
        r.msg = "成功";
        r.data = data;
        return r;
    }
    public static <T> Result<T> success(){
        Result<T> r = new Result<>();
        r.code = 200;
        r.msg = "请求成功";
        return r;
    }

    public static <T> Result<T> success(String msg,T data){
        Result<T> r = new Result<>();
        r.code = 200;
        r.msg = msg;
        r.data = data;
        return r;
    }

    public static <T> Result<T> error(){
        Result<T> r = new Result<>();
        r.code = 404;
        r.msg = "请求失败";
        return r;
    }
    public static <T> Result<T> error(String msg){
        Result<T> r = new Result<>();
        r.code = 404;
        r.msg = msg;
        return r;
    }
}
